<?php
/**
 * 获取体征数据--用于Android端的service同步数据
 * @authors Hex (hex@zpdchina.com)
 * @date    2017-03-09 11:09:02
 * @version $Id$
 */

class GettizhengdatajsonController extends Yaf_Controller_Abstract {

    public function indexAction()
    {
        //获取参数
        $request = $this->getRequest();
        $yiyuan_id = $request->getPost('yiyuan_id',0);
        $user_department = $request->getPost('user_department','');
        $zhuyuan_id = $request->getPost('zhuyuan_id','');
        $modify_time = $request->getPost('modify_time','');
        $json_data_str = $request->getPost('data','');
        $compression_http_data = $request->getPost('compression_http_data','off');

//        if(empty($yiyuan_id))
//            Utility::apiJsonError(30001, '医院编号不能为空');
        if(empty($user_department))
            Utility::apiJsonError(30010, '科室不能为空');
//        if(empty($json_data_str))
//            Utility::apiJsonError(30011, '上传数据不能为空');
        // 解压缩数据
        $json_data = json_decode(Utility::uncompress($json_data_str, $compression_http_data));

        $tizheng_mdl = new DataTizhengDataModel;
        $field_arr = $tizheng_mdl->_field_arr;
        $tizheng_data = $tizheng_mdl->getTizhengData($zhuyuan_id,$user_department,$json_data,$modify_time);
        $async_result = Utility::formatToSqlStrExtends($tizheng_data, 'zhuyuan_tizheng_lishi', 'update_sql', $field_arr);
        $result["response_state"] = "true";
        $result["response_info"] = "数据同步成功:)";
        if(empty($async_result)){
            $result["update_sql"] = array();
        }else{
            $result["update_sql"] = $async_result;
        }
        $result["error"] = 200;
        $result["msg"] = "";
        Utility::apiJsonResultExtends($result);

    }

}